package pimp.organizermanager;

import java.util.*;

public abstract class GlobalEvent
{
    private Date beginDate;
    private Date endDate;
    private ID id;
    private String description;
    private static LabelTree lableTree;


    public GlobalEvent(ID id, Date beginDate, Date endDate, String description) {
        this.id = id;
        this.beginDate = beginDate;
        this.endDate = endDate;
        this.description = description;
    }

    public String toString()
    {
        int size = description.length();
        if(size == 0)
            return "evt...";
        if(size > 13)
            return description.substring(0, 13) + "...";
        return description.substring(0, size) + "...";
    }
    public Date getBeginDate() {
        return beginDate;
    }

    public boolean setBeginDate(Date beginDate) {
        this.beginDate = beginDate;
        return true;
    }

    public String getDescription() {
        return description;
    }

    public boolean setDescription(String description) {
        this.description = description;
        return true;
    }

    public Date getEndDate() {
        return endDate;
    }

    public boolean setEndDate(Date endDate) {
        this.endDate = endDate;
        return true;
    }

    public ID getId() {
        return id;
    }

    public boolean setId(ID id) {
        this.id = id;
        return true;
    }

    public static LabelTree getLableTree() {
        return lableTree;
    }

    public static boolean setLableTree(LabelTree lableTree) {
        GlobalEvent.lableTree = lableTree;
        return true;
    }

    public abstract Node transformToNode();

    void addGlobalEventFieldsToNode(Node n) {
        
        n.addChild(new Node("beginDate", beginDate) );
        n.addChild( new Node("endDate", endDate) );
        n.addChild( new Node("id", id)) ;
        n.addChild( new Node("description", description) );
    }
}
